package com.micangcaihang.common.http;


import com.micangcaihang.common.http.exception.ApiException;

/**
 * @date: 2017-01-05 09:35
 */
public abstract class BaseSubscriber<T> extends ApiSubscriber<T> {

    T data;

    public BaseSubscriber() {
    }


    @Override
    protected void onStart() {
        super.onStart();
        doOnStart();
    }

    @Override
    public void onError(ApiException e) {
        doOnError(e);
    }

    @Override
    public void onNext(T t) {
        this.data = t;
        doOnNext(t);
    }

    @Override
    public void onComplete() {
        doOnComplete();
    }

    public T getData() {
        return data;
    }

    protected abstract void doOnStart();

    protected abstract void doOnNext(T t);

    protected abstract void doOnError(ApiException e);

    protected abstract void doOnComplete();
}
